package com.client.buttlefield.ui;

import javafx.animation.Interpolator;
import javafx.animation.PathTransition;
import javafx.animation.Animation.Status;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.util.Duration;;


public class Participant2{

	Integer currentX;
	Integer currentY;
	
	Byte ident;
	Circle circle;
	
	
	/***
	 * begin properties of this class
	 */
		
	protected void setIdent(Byte id) {
		this.ident = id;
	}
	
	protected Byte getIdent() {
		return ident;
	}
	/***
	 * end properties of this class
	 */
	
	PathTransition pathTransition;
	
	public Participant2(double x, double y, Color color) {
		circle = new Circle(x, y, 30);
		circle.setFill(color);
		
		pathTransition = new PathTransition();
		pathTransition.setNode(circle);
		pathTransition.setInterpolator(Interpolator.LINEAR);
	}
	
	void moving(double x, double y, int n){
		Path path = new Path();
        path.getElements().add(new MoveTo(currentX, currentY));
        path.getElements().add(new LineTo(x, y));

        pathTransition.setDuration(new Duration(100*n));
        pathTransition.setPath(path);
        pathTransition.play();
	}
	
	void stopMoving(double x, double y){
		if(pathTransition.getStatus() == Status.RUNNING){
			pathTransition.stop();
		}
		
		assignLocate(x, y);
	}
	
	public void assignLocate(double x,  double y){
		circle.setCenterX(x);
		circle.setCenterY(y);
	}
	
	public void assign(){
		Buttlefield b = Buttlefield.createButtle();
	//	b.addParticipant(circle);
	}
}
